LEX=lex
YACC=yacc
CFLAGS=-Wall -Wextra
CC=gcc

all:frontend

frontend:frontend.o symbol.o defines.o type_name_stack.o operator_stack.o function_signature.o array_signature.o scanner_frontend.c
	$(CC) -g $(CFLAGS) -o $@ $^
	
frontend.o : frontend.c symbol.h function_signature.h array_signature.h \
	type_name_stack.h defines.h \
	def_additive_expression.h \
	def_all_functions.h \
	def_argument_expression_list.h \
	def_comparison_expression.h \
	def_compound_statement.h \
	def_declaration.h \
	def_declaration_list.h \
	def_declarator.h \
	def_declarator_list.h \
	def_expression.h \
	def_expression_statement.h \
	def_external_declaration.h \
	def_function_definition.h \
	def_iteration_statement.h \
	def_jump_statement.h \
	def_multiplicative_expression.h \
	def_parameter_declaration.h \
	def_parameter_list.h \
	def_postfixe_expression.h \
	def_primary_expression.h \
	def_program.h \
	def_selection_statement.h \
	def_statement.h \
	def_statement_list.h \
	def_unary_expression.h
	$(CC) -g $(CFLAGS) -c $<

symbol.o : symbol.c symbol.h function_signature.h array_signature.h defines.h
	$(CC) -g $(CFLAGS) -c $<

function_signature.o : function_signature.c function_signature.h defines.h
	$(CC) -g $(CFLAGS) -c $<

array	_signature.o : array_signature.c array_signature.h defines.h
	$(CC) -g $(CFLAGS) -c $<

type_name_stack.o : type_name_stack.c type_name_stack.h defines.h
	$(CC) -g $(CFLAGS) -c $<


operator_stack.o : operator_stack.c operator_stack.h defines.h
	$(CC) -g $(CFLAGS) -c $<

defines.o : defines.c defines.h
	$(CC) -g $(CFLAGS) -c $<

frontend.c:frontend.y
	$(YACC) -o $@ --defines=frontend.tab.h $^

%.c:%.l
	$(LEX) -o $@ $^

clean:
	rm -f frontend.c scanner_frontend.c frontend.tab.h frontend *.o *.gch